const jwt = require('jsonwebtoken');
const str = "drytu;hgldkgohalkzdwuioerjswhfhsf"; //用于签名
// 创建token
function createToken(obj) {
    obj.time = Date.now();
    return jwt.sign(obj, str, { expiresIn: 60 * 60 })
}
// 验证token
function checkToken(token) {
    return new Promise((resolve, reject) => {
        jwt.verify(token, str, (err, data) => {
            if (err) {
                reject(err)
            }
            resolve(data)
        })
    })
}
module.exports = {
    createToken,
    checkToken
}